//存储层核心代码

/**
 * localStorange
 * 本地存储 
 * 
 */
// 定义常量
const STRINGTYPE = "string"

// 保存 修改 localStorage
export const setStorage = (key,data)=>{
 if(!key){
   return;
 }
//  检查是否为字符串类型
 if(typeof(data)!= STRINGTYPE){
   data=JSON.stringify(data);
 }
 localStorage.setItem(key,data);
}


// 读取localStorane
export const getStorage = (key)=>{
 if(!key){
   return;
 }
 return JSON.parse(localStorage.getItem(key));
}


// 删除localStorage
export const removeStorage = (key)=>{
 if(!key){
   return;
 }
 localStorage.removeItem(key)
} 


//  清空localStorage
export const clearStorage = ()=>{
 localStorage.clear()
}




